﻿using System;
using System.Collections.Generic;

namespace NmbpProject2.DboClasses
{
    public class CompApplication
    {
        public Person Person { get; set; }
        public List<ProgLanguage> ProgLanguages { get; set; }
        public DateTime Date { get; set; }
        public List<Category> Categories { get; set; }
        public Competition Competition { get; set; }

        public CompApplication(
            Person person,
            List<ProgLanguage> progLanguages,
            DateTime date,
            List<Category> categories)
        {
            Person = person;
            ProgLanguages = progLanguages;
            Date = date;
            Categories = categories;
        }

        public string LanguagesString
        {
            get
            {
                string languages = "";
                foreach (ProgLanguage language in ProgLanguages)
                {
                    if (language != null)
                    {
                        if (languages.Length == 0)
                        {
                            languages = String.Concat(languages, language.Name);
                        }
                        else
                        {
                            languages = String.Concat(languages, ", ", language.Name);
                        }
                    }
                }
                return languages;
            }
        }

        public string CategoriesString
        {
            get
            {
                string categories = "";
                foreach (Category category in Categories)
                {
                    if (category != null)
                    {
                        if (categories.Length == 0)
                        {
                            categories = String.Concat(categories, category.Name);
                        }
                        else
                        {
                            categories = String.Concat(categories, ", ", category.Name);
                        }
                    }
                }
                return categories;
            }
        }

        public override string ToString()
        {
            return Person.ToString();
        }
    }
}